/**
 * 设置cookie
 * @param {string} key 名称
 * @param {string} value 值
 * @param {number} exdays 有效期
 */
export function setCookie(key, value, exdays = 360) {
    var d = new Date();
    d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
    var expires = "expires=" + d.toGMTString();
    document.cookie = key + "=" + value + "; " + expires;
}

/**
 * 获取cookie
 * @param {string} key 名称
 * @returns 
 */
export function getCookie(key) {
    var name = key + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i].trim();
        if (c.indexOf(name) == 0) { return c.substring(name.length, c.length); }
    }
    return "";
}